<?php
get_header(); ?>
<?php get_menu(); ?>

<?php

global $tax;
global $page;

$page = ((get_query_var("page") != '')? get_query_var("page") : 1);

//$page = 2;
//var_dump($page);
$agrs = array(
    /* lấy theo trang hiện tại */
    'paged' => $page,

    /* số bài post ở mỗi trang */
    /* biến product_paging khai báo ở function.php define */
    'showposts' => product_paging,

    /* chỉ lấy post dạng product */
    'post_type' => 'product',

    'sort_by' => 'id'

);
?>
<?php $tax = new WP_query($agrs) ?>

<!-- Begin #shop-main-content -->
<div id="shop-main-content">

    <?php if ( $tax->have_posts() ) : ?>
    <!--Begin .pagination .pagination-top-->
    <div class="pagination pagination-top">
        <?php get_paging(); ?>
    </div>
    <!--End .pagination .pagination-top-->

    <!-- Begin product-item-->
    <ul id="list-product" class="clearfix">

        <?php woocommerce_product_subcategories(); ?>

        <?php $c = 0; ?>

        <?php while ( $tax->have_posts() ) : $tax->the_post(); ?>

        <?php //lay content tu archive-product ?>

        <?php woocommerce_get_template_part( 'content', 'product' ); ?>

        <?php $c++; ?>

        <?php if($c >= 3){
            echo "<div class='clearfix'></div>";
            $c = 0;  
        }?>

        <?php endwhile; // end of the loop. ?>

    </ul>
    <!-- End product-item-->

    <!--Begin .pagination pagination-bottom-->
    <div class="pagination-bottom">
        <?php get_paging(); ?>
    </div>
    <!--End .pagination pagination-bottom-->
    <?php else : ?>

    <?php if ( ! woocommerce_product_subcategories( array( 'before' => '<ul class="products">', 'after' => '</ul>' ) ) ) : ?>

        <p><?php _e( 'No products found which match your selection.', 'woocommerce' ); ?></p>

        <?php endif; ?>

    <?php endif; ?>
</div>
<!-- End #shop-main-content -->
<?php get_footer('shop'); ?>

<div id="modal-box" class="modal-box popup-catalogue-show">
    <div id="modal-box-inner">
        <div class="row clearfix">
            <div class="slider">
                <div class="slider-wrapper theme-default">
                    <div class="row modal-slider">
                        <img src="" alt="">
                    </div>
                </div>
            </div>
            <div class="info">
                <div class="tooltip blue-button">
                    <ul>
                        <li class="add_to_cart_btn">Thêm vào giỏ hàng</li>
                        <li class="add_to_cart_btn_clicked">Đặt hàng</li>
                    </ul>
                </div>
                <div id="slider-info"></div>
            </div>
        </div>

        <div class="row list-image">

        </div>
    </div>
</div>